<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>dologin (MywikiController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File app/controllers/mywiki_controller.rb, line 23</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dologin</span>
        <span class="ruby-ivar">@page</span> = <span class="ruby-value str">&quot;dologin&quot;</span>; <span class="ruby-identifier">p</span> <span class="ruby-value str">'Page: '</span><span class="ruby-operator">+</span><span class="ruby-ivar">@page</span>
        <span class="ruby-ivar">@usr</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user</span>]
        <span class="ruby-identifier">p</span> <span class="ruby-ivar">@usr</span>
        <span class="ruby-identifier">p</span> <span class="ruby-ivar">@usr</span>[<span class="ruby-identifier">:userid</span>]
        <span class="ruby-comment cmt">#@mywiki_user = MywikiUser.find(@usr[:userid])</span>
        <span class="ruby-ivar">@mywiki_user</span> = <span class="ruby-constant">MywikiUser</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;id = &quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@usr</span>[<span class="ruby-identifier">:userid</span>])
        <span class="ruby-identifier">p</span> <span class="ruby-ivar">@mywiki_user</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@mywiki_user</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
                <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:error</span>] = <span class="ruby-value str">'Login failed.'</span>
                <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:back</span>
        <span class="ruby-keyword kw">else</span>
                <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user_id</span>]=<span class="ruby-ivar">@usr</span>[<span class="ruby-identifier">:userid</span>]
                <span class="ruby-identifier">p</span> <span class="ruby-value str">'User id stored'</span><span class="ruby-operator">+</span><span class="ruby-identifier">session</span>[<span class="ruby-identifier">:user_id</span>]

                <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@mywiki_user</span>[<span class="ruby-value">0</span>][<span class="ruby-value str">'user'</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;admin&quot;</span>
                        <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'mywiki_user'</span>, <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:manage</span>
                <span class="ruby-keyword kw">else</span>                  
                        <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:index</span>
                <span class="ruby-keyword kw">end</span>           
        <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>